﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using JasRibbonApplicatie.Classes;

namespace JasRibbonApplicatie.Converters
{
    class EmailAdresConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is string)
            {
                return new EmailAdres(value as string);
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is EmailAdres)
            {
                EmailAdres mail = value as EmailAdres;
                return "[{\"personal\":\"" + mail.Naam + "\",\"mailbox\":\"" + mail.Mailbox + "\",\"host\":\"" + mail.Host + "\"}]";
            }
            return string.Empty;
        }

        #endregion
    }
}
